#!/usr/bin/perl

system("cat a.out |grep \"phase2\" > phase2.txt");
system("cat a.out |grep \"phase3_max\" > phase3.txt");

open(INPUT, "phase2.txt") or die "phase2.txt cannot be opened.\n";
open(OUTPUT, ">p2.txt") or die "p2.txt cannot be created.\n";
while($line = <INPUT>)
{
	chomp($line);
	@line_block = split(' ', $line);
	print OUTPUT "$line_block[2]\n";
}
close(INPUT);
close(OUTPUT);

open(INPUT, "phase3.txt") or die "phase3.txt cannot be opened.\n";
open(OUTPUT, ">p3.txt") or die "p3.txt cannot be created.\n";
while($line = <INPUT>)
{
        chomp($line);
        @line_block = split(' ', $line);
        print OUTPUT "$line_block[2]\n";
}
close(INPUT);
close(OUTPUT);
